package xc.src.demo02;

//测试守护线程
//虚拟机不用等待守护线程执行完毕
public class TestDaemon {
    public static void main(String[] args) {
        God god =new God();
        You you =new You();

        Thread thread =new Thread(god);
        thread.setDaemon(true);//设置为守护线程 默认为false，用户线程

        thread.start();

        new Thread(you).start();//用户线程启动了

    }

}
//上帝
class God implements Runnable{
    @Override
    public void run() {
        while (true){
            System.out.println("上帝保佑着你");
        }
    }
}

//你
class You implements Runnable{
    @Override
    public void run() {
        for (int i = 0; i < 36500; i++) {
            System.out.println("你一生都开心的活着");
        }
        System.out.println("-======goodbye! world"); //Hello,World!
    }
}